package com.ilovepostcard;

import java.util.Timer;
import java.util.TimerTask;

import android.content.Intent;
import android.os.Bundle;
import android.view.Window;

import com.ilovepostcard.controller.UserController;
import com.ilovepostcard.model.User;

public class LaunchActivity extends BaseActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
    	requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_launch);
    }
    
    @Override
    protected void onResume() {
        super.onResume();
        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            
            @Override
            public void run() {
                /* check user login */
                User user = UserController.getLoginUser(getApplicationContext());
                Intent intent = new Intent(getApplicationContext(), user == null ? HomeActivity.class : MainActivity.class);
                startActivity(intent);
                finish();
                timer.cancel();
            }
        }, 1000);
    }

}
